package pta06;

import java.util.Scanner;
class IllegalScoreException extends Exception{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public IllegalScoreException(String string) {
		super(string);
	}
	
}
class IllegalNameException extends Exception{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public IllegalNameException(String string) {
		super(string);
	}
	
}
class Student{
	private String name;
	private int score;
	public String getName() {
		return name;
	}
	public void setName(String name) throws IllegalNameException{
		if(name.charAt(0)>='0'&&name.charAt(0)<='9'){
			throw new IllegalNameException("the first char of name must not be digit, name="+name);
		}
		this.name=name;
	}
	public int getScore() {
		return score;
	}
	public void setScore(int score) {
		this.score = score;
	}
	@Override
	public String toString() {
		return "Student [name=" + name + ", score=" + score + "]";
	}
	public int addScore(int score) throws IllegalScoreException{
		if(score<0||score>100){
			throw new IllegalScoreException("score out of range, score="+score);
		}
		return score;
	}
}
public class pta654{

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		while(in.hasNext()){
			String str=in.next();
			if(str.equals("new")){
				Student student=new Student();
				try{
					student.setName(in.next());
					int score=in.nextInt();
					student.setScore(score);
					student.addScore(score);
					System.out.println(student.toString());
				}catch(IllegalNameException e){
					System.out.println(e);
					break;
			    } catch (IllegalScoreException e) {
					System.out.println(e);
				}
			}
		}
		in.close();
		System.out.println("scanner closed");
	}

}

